package com.own.business.question.entity.bo;

import com.own.business.question.common.base.ReplyEnvironment;
import com.own.business.question.entity.po.PracticeMistake;
import com.own.component.common.base.entity.BaseBo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * PracticeMistakeBo
 *
 * @author chenxueli
 * @date 2021/05/14 15:49:28
 */
@Schema(description = "练习错题表" + ConstantBeanSuffix.BO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class PracticeMistakeBo extends BaseBo<PracticeMistake> {

    @Schema(description = "用户id")
    private Long userId;

    @Schema(description = "流水id")
    private Long historyId;

    @Schema(description = "题目id")
    private Long questionId;

    @Schema(description = "用户答案")
    private String answer;

    @Schema(description = "作答环境")
    private ReplyEnvironment replyEnvironment;

    @Schema(description = "标记状态 0=未记住 1=已记住")
    private Integer status;

    /**
     * 转持久化对象
     *
     * @param entity 原持久化对象
     * @return 持久化对象
     */
    @Override
    public PracticeMistake toPo(PracticeMistake entity) {
        if (entity == null) {
            entity = new PracticeMistake();
        }
        entity.setFkUserId(userId);
        entity.setFkHistoryId(historyId);
        entity.setFkQuestionId(questionId);
        entity.setAnswer(answer);
        entity.setReplyEnvironment(replyEnvironment);
        entity.setStatus(status);
        return super.toPo(entity);
    }

}
